package domein;

/**
 * 
 * @author rensbonnez
 *
 */

public class DownloadFile
{
	private	String fileName;
	private Long fileSize;
	private String peerIp;
	private int downloadProgression;
	private String downloadStatus;
	
	public DownloadFile(String fileName, Long fileSize, String peerIp, int downloadProgression, String downloadStatus)
	{
		setFileName(fileName);
		setFileSize(fileSize);
		setPeerIp(peerIp);
		setDownloadProgression(downloadProgression);
		setDownloadStatus(downloadStatus);
	}
	
    public float getProgress() 
    {
        return ((float) getDownloadProgression() / getFileSize()) * 100;
    }

	public String[] toArrayList()
	{
		String[] fileArray = new String[5];
		fileArray[0] = getFileName();
		fileArray[1] = Integer.toString(Integer.parseInt(Long.toBinaryString(getFileSize()), 2)/1000) + "kb";
		fileArray[2] = getDownloadStatus();
		fileArray[3] = getPeerIp();
		
		return fileArray;
	}
	
	/**
	 * 
	 * Getters & Setters
	 * 
	 */
	
	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public Long getFileSize() {
		return fileSize;
	}

	public void setFileSize(Long fileSize) {
		this.fileSize = fileSize;
	}

	public String getPeerIp() {
		return peerIp;
	}

	public void setPeerIp(String peerIp) {
		this.peerIp = peerIp;
	}

	public int getDownloadProgression() {
		return downloadProgression;
	}

	public void setDownloadProgression(int downloadProgression) {
		this.downloadProgression = downloadProgression;
		PeerController.getInstance().notifyObservers();
	}

	public String getDownloadStatus() {
		return downloadStatus;
	}

	public void setDownloadStatus(String downloadStatus) {
		this.downloadStatus = downloadStatus;
		PeerController.getInstance().notifyObservers();
	}
}

